<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>修改密码</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${resRoot}/layui/css/layui.css" media="all"/>
	<link rel="stylesheet" href="${resRoot}/css/user.css" media="all" />
	<link rel="stylesheet" href="${resRoot}/layui/admin/admin.css" media="all" />
</head>
<body class="childrenBody">
<div class="layui-fluid">   
          <div class="layui-card">
	<div class="layui-form layui-card-header layuiadmin-card-header-auto">
	<form class="layui-form changePwd">
		<div style="margin:0 0 15px 110px;color:#f00;">旧密码请输入“123456”，新密码必须两次输入一致才能提交</div>
		<div class="layui-form-item">
		    <label class="layui-form-label">用户名</label>
		    <div class="layui-input-block">
		    	<input type="text" value="${user.loginName}" disabled class="layui-input layui-disabled">
		    </div>
		</div>
		<div class="layui-form-item">
		    <label class="layui-form-label">旧密码</label>
		    <div class="layui-input-block">
		    	<input type="password" value="" id="pwd" placeholder="请输入旧密码" lay-verify="required|oldPwd" class="layui-input pwd">
		    </div>
		</div>
		<div class="layui-form-item">
		    <label class="layui-form-label">新密码</label>
		    <div class="layui-input-block">
		    	<input type="password" value="" id="newpwd" placeholder="请输入新密码" lay-verify="required|newPwd" id="oldPwd" class="layui-input pwd">
		    </div>
		</div>
		<div class="layui-form-item">
		    <label class="layui-form-label">确认密码</label>
		    <div class="layui-input-block">
		    	<input type="password" value="" id="confirm" placeholder="请确认密码" lay-verify="required|confirmPwd" class="layui-input pwd">
		    </div>
		</div>
		<div class="layui-form-item">
		    <div class="layui-input-block">
		    	<button class="layui-btn" lay-submit=""  type="button" onclick="updatePwd();">立即修改</button>
		    </div>
		</div>
	</form>
	</div>
		</div>
		</div>
<script src="${resRoot}/layui/layui.js" charset="utf-8"></script>
<script src="${resRoot}/js/jquery.min.js?v=2.1.4"></script>
<script src="${resRoot}/layui/layui.all.js" charset="utf-8"></script>
	<script type="text/javascript">
     function updatePwd(){
    		var pwd = $("#pwd").val();
    	 	var newpwd = $("#newpwd").val();
    	 	var confirm = $("#confirm").val();
    	 $.ajax({
    		 type : "post",
    		 url : "${base}/sys/user/updatePwd?",
    		 data : {
    			 pwd : pwd,
    			 newpwd : newpwd,
    			 confirm : confirm,
    			 },
			 dataType : "json",
			 async : false,
			 success : function(data) {
				 flag  = data.message;
				 	if(flag!=0){
						if(flag == 1) {
						layer.msg('修改成功！', {
							  icon: 1,
							  time: 2000 //2秒关闭（如果不配置，默认是3秒）
							}, function(){
								window.location.href="${base}/sys/user/userlist";
							});  
					}else if(flag == 2){
						layer.msg('新密码与旧密码一致！', {
							  icon: 1,
							  time: 2000 //2秒关闭（如果不配置，默认是3秒）
							}, function(){
								
							});  
					}else if(flag == 3){
						layer.msg('两次输入密码不一致！', {
							  icon: 1,
							  time: 2000 //2秒关闭（如果不配置，默认是3秒）
							}, function(){
								
							});  
					}else if(flag == 4){
						layer.msg('旧密码错误！', {
							  icon: 1,
							  time: 2000 //2秒关闭（如果不配置，默认是3秒）
							}, function(){
								
							});  
					}
					
				 	}
					else {
						layer.alert("数据错误，请完善数据！");
					}
			 }
    	 });
     }    
	</script>
</body>
</html>